package com.klun.concDesign;

public class DaemonDemo {

    public static class DaemonTest extends Thread{
        @Override
        public void run() {
            while (true){
                System.out.println("这是一个守护线程，正在工作");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }
    }

    public static void main(String[] args) throws InterruptedException {
        DaemonTest d = new DaemonTest();
        d.setDaemon(true);//设置为守护线程
        d.start();
        Thread.sleep(3000);
    }

}
